﻿using System;
using System.Collections.Generic;
using Assist;
using Autodesk.Revit.DB;
using YJKArchUtils.Utils;
using YJKRevitDimensionText.OneKeyPlanDim.Utility;

namespace YJKRevitDimensionText.OneKeyPlanDim.LevelDim
{
	public class CommonParapet
	{
		public CommonParapet(Autodesk.Revit.DB.Document doc)
		{
			this.m_doc = doc;
		}

		public void AnalysisWall(Wall wall)
		{
			this.m_dir = wall.Orientation;
			this.m_dLevelVal = this.GetWallLevel(this.m_doc, wall);
			this.m_stringLevel = (AssistFunc.feetToMM(this.m_dLevelVal) / 1000.0).ToString("f3") + "(结)";
		}

		public bool IsCommonWall(CommonParapet commonParapet)
		{
			return Geometry.IsEqual(this.m_dLevelVal, commonParapet.m_dLevelVal) && this.m_dir.IsAlmostEqualTo(commonParapet.m_dir);
		}

		public void CreateDim(LevelDimData levelDimData)
		{
			levelDimData.DimVal = this.m_stringLevel;
			FamilyInstance familyInstance = levelDimData.CreateLevelDim();
			if (familyInstance == null)
			{
				return;
			}
			if (!(familyInstance is AnnotationSymbol))
			{
				return;
			}
			CurveLoop levelDimCurveLoop = OcclusionArea.GetLevelDimCurveLoop(this.m_doc, familyInstance);
			OcclusionArea.GetInstance().m_lstLevelDimCvLoop.Add(levelDimCurveLoop);
		}

		private Wall GetLongWall()
		{
			return null;
		}

		private double GetWallLevel(Autodesk.Revit.DB.Document doc, Wall wall)
		{
			BoundingBoxXYZ boundingBoxXYZ = wall.get_BoundingBox(null);
			if (boundingBoxXYZ == null)
			{
				return 0.0;
			}
			return boundingBoxXYZ.Max.Z;
		}

		public XYZ m_dir;

		public double m_dLevelVal;

		public string m_stringLevel = string.Empty;

		public List<Wall> m_lstDaughterWall = new List<Wall>();

		private Document m_doc;
	}
}
